package com.openvas.core.gas.vo.dw;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;

public abstract class BaseWapper {
	
	 public  Map<String,Object> convertThis2Map() {
			Map<String,Object> map = new HashMap<String,Object>();
			this.getClass().getDeclaredFields();
			Field[] fields = this.getClass().getDeclaredFields();
			for (int i = 0; i < fields.length; i++) {
				String filedName = fields[i].getName();
				if("serialVersionUID".equals(filedName)){
					continue;
				}
				StringBuilder sb = new StringBuilder("get");
				sb.append(filedName.substring(0, 1).toUpperCase());
				sb.append(filedName.substring(1, filedName.length()));
				try {
					Method method = this.getClass().getMethod(sb.toString());
					Object object = method.invoke(this);
					if(object != null){
						map.put(filedName, object);
					}
				} catch (Exception e) {
					e.printStackTrace();
				} 
			}
			//map.put("MAX_SIZE", MAX_SIZE);
			return map;
		}
}
